﻿     #define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>

using namespace std;

namespace jc2
{
    class Person
{
public:
    // 进⼊校园/图书馆/实验室刷⼆维码等⾝份认证
    void identity()
    {
        cout << "void identity()" << _name << endl;
    }
protected:

    string _name = "某某"; // 姓名
    string _address; // 地址
    string _tel; // 电话
    int _age = 18; // 年龄

};

class Student : public Person
{
public:
    // 学习
    void study()
    {
        // ...
    }
protected:
    int _stuid; // 学号
};

class Teacher : public Person
{
public:
    // 授课
    void teaching()
    {
        //...
    }
protected:
    string title; // 职称
};
}

int main2()
{
    jc2::Student s;
    jc2::Teacher t;
    s.identity();
    t.identity();

    return 0;
}

namespace jc
{
    class Person
    {
    public:
        Person(const char* name)
            :_name(name)
        {
            cout << "父类默认构造" << endl;
        }
        Person(const Person& s)
            :_name(s._name)
        {
            cout << "父类拷贝构造" << endl;
        }

        Person& operator=(const Person& p)
        {
            cout << "父类运算符重载" << endl;
            if (this != &p)
            {
                _name = p._name;
            }
            return *this;
        }

        ~Person()
        {
            cout << "父类析构" << endl;
        }

    private:
        string _name;
    };

    class Student : public Person
    {
    public:
        Student(int age, const char* address, const char* name)
            :_age(age)
            ,_address(address)
            ,Person(name)
        {
            cout << " 子类默认构造" << endl;
        }

        Student(const Student& s)
            :Person(s)
            , _age(s._age)
            , _address(s._address)
        {
            cout << "子类拷贝构造" << endl;
        }

        Student& operator=(const Student& s)
        {
            cout << "子类运算符重载" << endl;
            if (this != &s)
            {
                _age = s._age;
                _address = s._address;
                Person::operator=(s);
            }
            return *this;
        }

        ~Student()
        {
            cout << "子类析构" << endl;
        }

    private:
        int _age;
        string _address;
    };
}

int main()
{
    jc::Student s(18, "kivotos", "kayoko");
    jc::Student s2(s);
    return 0;
}//